<!DOCTYPE html>
<html>
<head>
	<title>Add / Delete items</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<link rel="stylesheet" type="text/css" href="../common/demo_style.css"/>
	<script>
		var myTree;
		function doOnLoad(){
			myTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			myTree.setImagePath("../../../skins/web/imgs/dhxtree_web/");
			myTree.load("../common/tree.xml");
		}
		function fixImage(id){
			switch(myTree.getLevel(id)){
			case 1:
				myTree.setItemImage2(id,'folderClosed.gif','folderOpen.gif','folderClosed.gif');
				break;
			case 2:
				myTree.setItemImage2(id,'folderClosed.gif','folderOpen.gif','folderClosed.gif');
				break;
			case 3:
				myTree.setItemImage2(id,'folderClosed.gif','folderOpen.gif','folderClosed.gif');
				break;
			default:
				myTree.setItemImage2(id,'leaf.gif','folderClosed.gif','folderOpen.gif');
				break;
			}
		}
	</script>
</head>
<body onload="doOnLoad()">
	<h1>Add / Delete items</h1>
	<p>You can freely customize a tree view. This sample illustrates that the tree items can be easily
		added/deleted dynamically through the graphical user interface.
		You can insert new sibling or child node as well.
		This feature allows you to configure a DHTML tree menu effortlessly.</p>
	<table>
		<tr>
			<td valign="top">
				<div id="treeboxbox_tree" class="tree_demo_samples"></div>
			</td>
				<td rowspan="2" style="padding-left:25px" valign="top">
				<a href="javascript:void(0);" onClick="var d=new Date(); myTree.insertNewItem(myTree.getSelectedItemId(),d.valueOf(),document.getElementById('ed1').value,0,0,0,0,'SELECT'); fixImage(d.valueOf());">Insert new child item</a> Item label <input type="text" value="New item" id="ed1"><br><br>
				<a href="javascript:void(0);" onClick="var d=new Date(); myTree.insertNewNext(myTree.getSelectedItemId(),d.valueOf(),document.getElementById('ed2').value,0,0,0,0,'SELECT'); fixImage(d.valueOf());">Insert new item next</a> Item label <input type="text" value="New item" id="ed2"><br><br>
				<a href="javascript:void(0);" onClick="myTree.deleteItem(myTree.getSelectedItemId(),true);">Delete item</a><br><br>
			</td>
		</tr>
	</table>
	<ul>
		<li>zeros passed to the function for arguments 4-7 (function to call on select, images) mean the usage of default values for them</li>
		<li>Last argument is a comma delimited string of the following possible value (upper case only):</li>
		<li type="circle">SELECT - move selection to this node after inserting</li>
		<li type="circle">CALL - call function on select</li>
		<li type="circle">TOP - add node to the top position </li>
		<li type="circle">CHILD - node has child items</li>
		<li type="circle">CHECKED - checkbox is checked (if exists)</li>
	</ul>
</body>
</html>
